/**     
 * @Title: IndexController.java   
 * @Package me.springboot.netty.web   
 * @Description: TODO
 * @author weiwei 
 * @date 2017年8月28日 下午2:10:51   
 * @version V1.0     
 */
package me.springboot.netty.web;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @ClassName: IndexController
 * @Description: TODO
 * @author weiwei
 * @date 2017年8月28日 下午2:10:51
 * 
 */
@RestController
@EnableWebMvc
@RequestMapping("/index/")
public class IndexController {

	@PostMapping(value = "json")
	@ResponseBody
	public String json() throws JsonProcessingException {
		Map<String, Object> map = new HashMap<String, Object>(2);
		map.put("code", 200);
		map.put("msg", "OK");
		ObjectMapper mapper = new ObjectMapper();
		return mapper.writeValueAsString(map);
	}

	@GetMapping
	public String index() {
		return "OK";
	}
}